# coding=utf-8


import cx_Oracle


def conn_oracle(name, password, linkstr, sqlstr):
    """
    连接oracle数据库，查询数据
    :param name:
    :param password:
    :param linkstr:
    :param sqlstr:
    :return: rs
    """
    conn = cx_Oracle.connect(name, password, linkstr)  # 连接数据库
    c = conn.cursor()  # 获取cursor
    x = c.execute(sqlstr)  # 使用cursor进行各种操作
    rs = x.fetchall()

    c.close()  # 关闭cursor
    conn.close()
    return rs


if __name__ == "__main__":
    sql = ' SELECT bc.creditid,bc.businesstype FROM business_contract bc WHERE bc.serialno= \'34351035001\''
    dd = conn_oracle('uatCXF', 'OMYWrXOJRRMC', '10.83.24.2:1521/test_uat', sql)
    print(dd)
